// ignore_for_file: empty_constructor_bodies

import 'package:flutter/material.dart';
import 'package:flutterdemo/common/calc.dart';
import 'package:flutterdemo/components/img.dart';

class Avatar extends StatelessWidget {
  double? size;
  String url;
  double? borderRadius;
  Avatar(this.url, {this.size, this.borderRadius});

  @override
  Widget build(BuildContext context) {
    return Container(
        decoration:
            BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(4.0))),
        height: size ?? Calc.width(90),
        width: size ?? Calc.width(90),
        child: LayoutBuilder(builder: (context, constraints) {
          return ClipRRect(
            borderRadius: BorderRadius.circular(
                borderRadius ?? constraints.maxWidth * 0.5),
            child: Img(url),
          );
        }));
  }
}
